import 'package:flutter/cupertino.dart';

import '../../../../lib_baseview/widget/dialogs.dart';
import '../../interface/chat_room_leaf_interface.dart';

class MicSelectPageModel extends ChatRoomChangeNotifier {
  // Channel? get channel => roomModel.channel;
  // SimpleChannelUser currUserInfo;
  // SimpleChannelUserSlot? selectedSeat;
  int selectedPosition = 0;

  // MicSelectPageModel(this.currUserInfo); //当前要被选择上麦的用户信息

  MicSelectPageModel(); //当前要被选择上麦的用户信息

  // selectSeat(SimpleChannelUserSlot? user, int position) {
  //   selectedSeat = user;
  //   selectedPosition = position;
  //   notifyListeners();
  // }

  confirm(BuildContext context) async {
    showToast('result.errorMsg');
    // var channelUpMic = ChannelGrantUpMic.create()
    //   ..uid = currUserInfo.id
    //   ..position = selectedPosition;
    // var result = await RtcApi.instance.updateChannel(ChannelUpdate.create()
    //   ..channel = roomModel.channel!.channelId
    //   ..grantUpMic = channelUpMic);
    // if (result.isSuccess) {
    //   Navigator.of(context).pop();
    // } else {
    //   showToast(T.current!.hug_up_mic_fail_reason(result.errorMsg ?? ''));
    // }
  }

  // /// 申请上麦
  // Future<bool> joinMic(BuildContext context, MicSeatInfo? seatInfo) async {
  //   _log("enter joinMic $seatInfo");
  //   if (seatInfo == null) return false;
  //   var position = micSeatList.indexOf(seatInfo);
  //
  //   if (channel == null) {
  //     _log("channel is NULL");
  //     return false;
  //   }
  //   if (currUserInfo == null) {
  //     _log("currUserInfo is NULL");
  //     return false;
  //   }
  //   ChannelUpdate req = ChannelUpdate();
  //   req.channel = channel!.channelId;
  //   if (seatInfo.userType.atLeastManager()) {
  //     req.requestManage = ChannelRequestManage();
  //     req.requestManage.position = position;
  //   } else {
  //     req.grantPublisher = ChannelGrantPublisher()
  //       ..user = currUserInfo!.id
  //       ..position = position;
  //   }
  //   _log("joinMic ${req.toProto3Json()}");
  //   var result = await RtcApi.instance.updateChannel(req);
  //   if (result.isSuccess) {
  //     showToast("上麦成功");
  //     if (mounted) {
  //       Navigator.pop(context);
  //     }
  //   } else {
  //     showToast(result.errorMsg ?? "");
  //   }
  //   return true;
  // }
  //
  // _log(String msg) {
  //   RLog.d("[RoomMainPageModel]WRF $msg");
  // }

  @override
  observeMessage(int messageId, data) {}
}
